<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>滴答办公系统-部门列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script src="media/js/jquery.min.js" ></script>
	<script type="text/javascript">
		function changepagesize(pagesize) {
			// alert(pagesize)
			location.href="/Depart_list?pageindex=1&pagesize="+pagesize;
		}
		function jumppage(pagecount,pagesize) {
			var pageNum = $("#pageNum").val();
			// alert(pageNum);
			var regex = /^[1-9]\d*$/;
			if (regex.test(pageNum) == true) {
				//alert("是一个数字~");
				if (pageNum >= 1 && pageNum <= pagecount) {
					location.href = "/Depart_list?pageindex=" + pageNum + "&pagesize=" + pagesize;
				} else {
					alert("请输入一个合法的数字!")
				}
			} else {
				alert("请输入一个数字!")
			}
		}
	</script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>部门名称</td>
					<td>部门人数</td>
					<td>成立日期</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<tr th:id="|tr_${d.id}|" th:each="d:${PageUtils.recods}">
					<td th:text="${d.id}">03</td>
					<td th:text="${d.name}">教务部</td>
					<td>0</td>
					<td th:text="${d.createtime}">2015-10-01</td>
					<td><a class="layui-btn layui-btn-mini" th:href="|/Depart_toupdate/${d.id}|">编辑</a>
						<a class="layui-btn layui-btn-danger layui-btn-mini" th:onclick="|deleteCourse(${d.id});|">删除</a></td>
				</tr>
			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
						   <a th:href="|/Depart_list?pageindex=${PageUtils.pageIndex-1}&pagesize=${PageUtils.pagesize} |" th:if="${PageUtils.pageIndex>1}" class="layui-laypage-prev" data-page="0">
							    <i class="layui-icon">&lt;</i>
						   </a> 
<!--							    <span style="color:#009688;font-weight: bold;">1</span> -->
<!--		                                  循环拿到下标                                   往后台传输数据（注意，名字必须与后台一一对应）  ？连接传递的数据           向<a>标签中间传递数据   修改样式   -->
							    <a href="#" th:each="num:${PageUtils.numbers}" th:href="|/Depart_list?pageindex=${num}&pagesize=${PageUtils.pagesize}|" th:text="${num}"  th:style="${PageUtils.pageIndex==num}?'color:#009688;font-weight: bold;':''">xxx</a>
<!--			|/Depart_list?pageIndex=${DepartPageBean.index-1}|-->
			<a th:href="|/Depart_list?pageindex=${PageUtils.pageIndex+1}&pagesize=${PageUtils.pagesize}|" th:if="${PageUtils.pageIndex<PageUtils.pagecount}" class="layui-laypage-next" data-page="2">
							    <i class="layui-icon">&gt;	</i>
							</a>
<!--			<a th:each="num:${PageUtils.numbers}" th:href="|/Depart_list?pageIndex=${num}&pagesize=${PageUtils.pagesize}|" th:style="${PageUtils.pageIndex==num}?'color:#009688;font-weight: bold;':''" th:text="${num}">-->
<!--				xxxx-->
<!--			</a>-->
<!--			<a th:href="|/depart_list?pageIndex=${pageUtils.pageIndex+1}&pageSize=${pageUtils.pageSize}|"-->
<!--			   th:if="${PageUtils.pageIndex<PageUtils.pagecount}" class="layui-laypage-next" data-page="2">-->
<!--				<i class="layui-icon">&gt;</i>-->
<!--			</a>-->
							<span class="layui-laypage-skip">到第
							   <input type="text" min="1" th:value="${PageUtils.pageIndex}" class="layui-input" id="pageNum">页
								<button type="button" class="layui-laypage-btn" th:onclick="|jumppage(${PageUtils.pagecount},${PageUtils.pagesize});|">确定</button>
							</span> 
							<span class="layui-laypage-count">共 [[${PageUtils.totalpage}]] 条</span>
							<span class="layui-laypage-count">共 [[${PageUtils.pagecount}]] 页</span>
							<span class="layui-laypage-limits">
							    <select lay-ignore="" onchange="changepagesize(this.value)">
							        <option value="5" th:selected="${PageUtils.pagesize==5}">5 条/页</option>
									<option value="10" th:selected="${PageUtils.pagesize==10}">10 条/页</option>
									<option value="20" th:selected="${PageUtils.pagesize==20}">20 条/页</option>
									<option value="30" th:selected="${PageUtils.pagesize==30}">30 条/页</option>
									<option value="40" th:selected="${PageUtils.pagesize==40}">40 条/页</option>
							</select>
							</span>
						</div>
	</div>
	<script src="media/layui/layui.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(id){
		   layui.use('table', function() {
			   layer.confirm('是否确认删除部门?',function(index) {
			   	$.getJSON("/Depart_delect","id="+id,function (result) {
			   		// alert(result)
			   		if (result){
						layer.msg("删除成功", {icon : 6});
						$("#tr_"+id).fadeOut(1000,function () {
							window.location.reload();
						})
					}else {
						layer.msg("删除失败", {icon : 5});

					}
				})
			   });
		   });
	   }
	</script>
	
	
</body>
</html>